using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using FarseerGames.FarseerPhysics.Dynamics;
using FarseerGames.FarseerPhysics.Collisions;
using Microsoft.Xna.Framework.Graphics;

namespace RacerGame
{
	internal abstract class ColObject
	{
		protected Entity entity;
		private Body body;
		public Geom Geom { get { return geom; } }
		protected Geom geom;
		public Body Body { get { return body; } }
		public Vector3 Position { get { return entity.Position; } }
		public Vector2 Position2D { get { return entity.Position2D; } }
		public Color Color = Color.Lime;
		public Vector3 LinearVelocity { get { return new Vector3(body.LinearVelocity.X, 0, body.LinearVelocity.Y); } }

		public ColObject(Entity entity, Body body) {
			this.entity = entity;
			this.body = body;			
			UpdateBodyPosition();
		}

		public bool Enabled {
			get {
				return body.Enabled;
			}
			set {
				body.Enabled = value;				
			}
		}


		public void UpdateEntityPosition() {
			entity.Position2D = body.Position;
			entity.UpdatePositionMatrix();
		}

		public void UpdateBodyPosition() {
			body.Position = Position2D;
		}

		public abstract bool Within(Vector2 point);
		
		public abstract void Draw(Camera camera);

		public virtual void Die(){
			RacerGame.Simulator.Remove(body);
			RacerGame.Simulator.Remove(geom);
		}
	}
}
